/**
 * Created by LuckyYe on 2016/8/10.
 */
angular.module('service.expertsys', [
        "ngResource",
        "ngStorage"
    ])


    .service('ExpertsysService', ['$resource', '$http', function ($resource, $http) {

        var baseUrl = mall_expert + "expert/";
        //var baseUrl = "http://localhost:8080/expert/"
        var tocpicUrl = mall_expert + "topic/";

        //通过tid删除问题
        this.removeTopicQueByTid = function (tid) {
            var remove_topicQue = $resource(tocpicUrl + ":topicid");
            return remove_topicQue.remove({topicid: tid});
        }

        //通过tid修改topic
        this.updateTopicQueByTid = function (topic) {
            var update_topicQue = $resource(tocpicUrl + "updata/:topicid");
            return update_topicQue.save({topicid: topic.topicid}, topic);
        }

        //得到topic By tid
        this.getTopicQueByTid = function (tId) {
            var topicQue = $resource(tocpicUrl + ":topicid");
            return topicQue.get({topicid: tId});
        }

        //得到热门问题 By expertsysId
        this.getHotTopicQue = function (eId) {
            var hotTopicQue = $resource(tocpicUrl + "showhost/:expertsysId");
            return hotTopicQue.query({expertsysId: eId});
        }

        //得到所有topic By expertsysId
        this.getTopicQueByEid = function (eId) {
            var topicQues = $resource(tocpicUrl + "showque/:expertsysId");
            return topicQues.query({expertsysId: eId});
        }

        //得到全部topic
        this.getTopicQue = function () {
            var topicQue_all = $resource(tocpicUrl);
            return topicQue_all.query();
        }

        //得到用户提出的所有问题By userid
        this.getTOpicQueByUid = function (uId) {
            var topicQue_user = $resource(tocpicUrl + "byuserid/:userId");
            return topicQue_user.query({userId: uId});
        }

        //限制条数显示专家
        this.getExpertsysByPage = function (n, num,eCategory) {
            var expertsys_byPage = $resource(baseUrl + "expert/:page");
            return expertsys_byPage.query({page: n, num: num,category:eCategory});
        }

        //获取所有专家列表
        this.getExpertsysList = function () {
            var expertsys_all = $resource(baseUrl);
            return expertsys_all.query();
        }

        //通过ID获取所有专家详细信息
        this.getExpertsysById = function (eId) {
            var userid_res = $resource(baseUrl + "/:id");
            return userid_res.get({id: eId});
        }

        //通过ID获取用户表中专家的详细信息
        this.getUserById = function (eId) {
            var user = $resource(mall_uc + "user/:id");
            return user.get({id: eId});
        }

        //得到全部用户列表所有数据
        this.getUserList = function () {
            var UserList = $resource(mall_uc + "user");
            return UserList.query();
        }
    }])